import React from 'react'
import My from './components/My'
import Find from './components/Find'
export default class App extends React.Component {
  state = {
    currentHash: ''
  }
  componentDidMount() {
    window.onhashchange = () => {
      console.log(11);
      console.log(window.location.hash);
      const hash = window.location.hash.slice(1)
      console.log(hash);
      this.setState({
        currentHash: hash
      })
    }
  }

  render() {
    return (
      <div>
        <h2>伪网易云音乐</h2>
        <button onClick={this.MyMusice}>我的音乐</button>
        <button onClick={this.FindMusice}>发现音乐</button>
        {this.state.currentHash === '/My' ? <My></My> : ''}
        {this.state.currentHash === '/Find' ? <Find></Find> : ''}
      </div>
    )
  }
  MyMusice = () => {
    window.location.hash = "#/My"
  }
  FindMusice = () => {
    window.location.hash = "#/Find"
  }

}
